package org.xxforest.game.core.scenes.scene2d.events.type;

import org.xxforest.game.core.scenes.scene2d.XXNode;
import org.xxforest.game.core.scenes.scene2d.events.XXEvent;
import org.xxforest.game.core.scenes.scene2d.events.XXEventType;
import org.xxforest.game.core.utils.XXPoint;

import com.badlogic.gdx.utils.Pools;

public class XXTouchEvent implements XXEvent{

	private XXNode target ;
	private XXEventType eventType ;
	private float x , y ;
	
	public static XXTouchEvent create(){
		return Pools.obtain(XXTouchEvent.class);
	}
	
	public void setValues(XXNode target , float x , float y){
		this.target = target ;
		this.x = x ;
		this.y = y ;
	}
	
	public XXTouchEvent longTouchEvent(){
		eventType = XXEventType.LONG_TOUCH ;
		return this ;
	}
	
	public XXTouchEvent clickDownEvent(){
		eventType = XXEventType.CLICK_DOWN ;
		return this ;
	}
	
	public XXTouchEvent clickUpEvent(){
		eventType = XXEventType.CLICK_UP ;
		return this ;
	}
	
	public XXTouchEvent doubleEvent(){
		eventType = XXEventType.DOUBLE_CLICK ;
		return this ;
	}
	
	@Override
	public void dispose() {
		target = null ;
		eventType = null ;
		Pools.free(this);
	}

	@Override
	public XXEventType getEventType() {
		return eventType;
	}

	public float getX() {
		return x;
	}

	public float getY() {
		return y;
	}

	public XXNode getTarget() {
		return target;
	}

	public XXPoint getPoint() {
		return XXPoint.create(x, y);
	}
	
}
